<?php

// lookup the most recent instance
$query = "SELECT id, state, days, style, start_node, stale_dn, track_id"
   		." FROM n_adc WHERE style LIKE 'stale' AND state != 3";
$result = db_query($query);
if(!$result) {
	echo "error: wasn't able to find list in the instance\n";
	exit(1);
}
// loop through until we have the last instance
$instance = mysql_fetch_assoc($result);
while($next = mysql_fetch_assoc($result)) {
	$instance = $next;
}

// display ad objects pending deletion
$query = "SELECT * FROM n_adc_". $instance["id"] ." WHERE isIgnore=0 ORDER BY netbios ASC";
$result = db_query($query);
if(!$result) {
	echo "error: wasn't able to find list in the instance\n";
	exit(1);
}
?>

<script>
tables.push([
	"table_stale_pending",
	google.visualization.arrayToDataTable([
		['Machine Account', 'Location']

<?php
while($next = mysql_fetch_assoc($result)) {
	// get simple formant of dn
	$tmpstr = "";
	$parts = explode(",", $next["dn_orig"]);
	$parts = array_reverse($parts);
	foreach($parts as $part) {
		$pieces = explode("=", $part);
		$tmpstr .= "/". $pieces[1];
	}
	$tmpstr = ltrim($tmpstr, "/");

	echo ",["
		."'". $next["netbios"] ."'"
		.",'".  $tmpstr ."'"
		."]\n";
}

?>
		])
	]);
</script>
